﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DynamicTestApp.DynamicXMLReader.DynamicXml;
using Prologis.ObjectExtensions;
using System.ComponentModel;

namespace DynamicTest
{
    [TestClass]
    public class DynamicXmlTest2
    {
        [TestMethod]
        public void TestMethod1()
        {

            dynamic dyn = "123";
            Type type = dyn.GetType();
            string str = dyn;
        }


        [TestMethod]
        public void TestMethod2()
        {

            string xml = @"
                         <printers>
                            <printer ip='1.1.1.1' port='5000'>
                              <gruppe name='1' linie='L001' layout='Layout1'/>
                              <gruppe name='2' linie='L002' layout='Layout1'/>
                            </printer>
                            <printer ip='2.2.2.2' port='5000'>
                              <gruppe name='1' linie='L003' layout='Layout1'/>
                              <gruppe name='2' linie='L004' layout='Layout1'/>
                            </printer>
                            <printer ip='3.3.3.3' port='5000'>
                              <gruppe name='1' linie='L005' layout='Layout1'/>
                              <gruppe name='2' linie='L006' layout='Layout1'/>
                            </printer>
                          </printers>";



            // the variable xml contains the string text of an XML document
            dynamic printers = new DynamicXml(xml);
            List<PrinterConfig> printerConfigList = new List<PrinterConfig>();
                        
            //Elementcount
            int printerCount = printers.printer.Count;

            foreach (dynamic printerElement in printers.printer)
            {
                PrinterConfig printerConfig = new PrinterConfig();
                printerConfig.Ip = printerElement.ip;
                printerConfig.Port = int.Parse(printerElement.port);
                printerConfig.Gruppe1.Name = printerElement.gruppe.name;
                printerConfig.Gruppe1.Linie = printerElement.gruppe.linie;
                printerConfig.Gruppe1.Layout = printerElement.gruppe.layout;
                printerConfig.Gruppe2.Name = printerElement.gruppe.name;
                printerConfig.Gruppe2.Linie = printerElement.gruppe.linie;
                printerConfig.Gruppe2.Layout = printerElement.gruppe.layout;
                printerConfigList.Add(printerConfig);
            }

            string s = "§";
        }

              

         

    

    }
}

